<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
<meta charset="utf-8">
<meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no" name="viewport">
<meta content="yes" name="apple-mobile-web-app-capable">
<meta content="black" name="apple-mobile-web-app-status-bar-style">
<meta content="telephone=no" name="format-detection">
<meta content="email=no" name="format-detection">
<title>计划列表</title>
<link th:href="@{/ksdH5/css/public/mui/mui.css}" rel="stylesheet"/>
<script th:src="@{/ksdH5/js/public/mui/mui.min.js}"></script>
<script th:src="@{/ksdH5/js/public/jquery.min.js}"></script>
<script th:src="@{/ksdH5/js/public/public.js}"></script>
<link th:href="@{/ksdH5/css/public/leftNav.css}" rel="stylesheet"/>
<link th:href="@{/ksdH5/css/planList/planList.css}" rel="stylesheet"/>
</head>
<body>
<!--头部-->
<div class="headerBox">
	<a href="javascript:void(0);" class="headerBox_left"><img th:src="@{/ksdH5/img/header_leftIcon.png}"></a>
	<!--关闭按钮-->
	<a href="javascript:void(0);" class="headerBox_leftClose"><img th:src="@{/ksdH5/img/login/closeBnt.png}"></a>
	<span>计划列表</span>
	<a th:href="${#httpServletRequest.getScheme()+'://'+#httpServletRequest.getServerName()+':'+#httpServletRequest.getServerPort()+#httpServletRequest.getContextPath()+'/h5/plan/add'}"  class="headerBox_right"><img th:src="@{/ksdH5/img/header_rightIcon.png}"></a>
</div>
<div class="mui-content">
<ul class="planList_listBox" id="plan_list_ul">
	
</ul>
<!--暂无数据-->
<div class="planList_noData" style="display: none;">
	<div class="planList_noData_img">
		<img class="" th:src="@{/ksdH5/img/planList/jhlb_zwsj.png}" />
	</div>
	<div class="planList_noData_title">您暂时还没有计划哦</div>
	<div class="planList_noData_cont">赶快点击右上角添加按钮，制定计划吧！</div>
</div>
</div>
<!--左侧导航-->
<!--左侧导航-->
<!-- 引入导航页面 -->

<!-- ecr/html/includeNav:是子页面的文件路径 ；myNav：是子页面中被引用代码块的名称
（如th:fragment="myNav"） -->
<div th:replace="h5/ksdH5IncludeNav :: ksdH5Nav"  ></div>
<div class="huiseBox"></div>
</body>

<script type="text/javascript" th:inline="javascript">
//获得项目根路径
var ctx = [[@{/}]];
</script>
 <script type="text/javascript">
 var prefix = ctx +"h5";
    	$(function(){
    		//指定第一个菜单样式选中
    		$(".leftNavContBox_contBox li").eq(3).find("a").addClass('leftNavContBox_contBox_bnt_active');
    		//查询用户信息
    		 $.ajax({
					url : ctx+ "h5/merInfo",
					type : "POST",
					success : function(re) {
					if (re.status == "SUCCESS") {
						var merchant = re.merchant;
						$("#nav_mer_name").text(merchant.merchantCnName);
						$("#nav_mer_phone").text(merchant.phone);
						var level = merchant.level;
						if(level=="1"){
							$("#nav_mer_level").text("免费用户");
						} else if(level=="2"){
							$("#nav_mer_level").text("经理（未激活）");
						} else if(level=="3"){
							$("#nav_mer_level").text("经理");
						}
						//指定头像
						var headImg = re.headImg;
						if(headImg != ""&& headImg !=null){
							$("#head_img").attr('src',headImg);
						}
					} else {
						
					}
				}
			}); 
    		//查询用户计划列表信息
    		 $.ajax({
					url : prefix+"/plan/list",
					type : "POST",
					success : function(re) {
						if (re.status == "out") { //session过期
							//跳转登陆页面
							location.href = prefix + '/login';
						} else if(re.status == "SUCCESS") {
							var obj = re.obj;
							var planList= $.parseJSON(obj.planList);
							if(planList.length>0){
								var planStr="";
								$.each(planList,function(index,plan){
									planStr +="<li>";
									planStr +="<a href='"+prefix+"/plan/detail?id="+plan.id+"'>";
									//判断计划明细状态选择不同图标
									if(plan.status=="10A"){
										planStr +="<img src='/ksdH5/img/planList/plan_wzxIcon.png' class='planList_listBox_icon'>";
									}else if(plan.status=="10C"){//已取消
										planStr +="<img src='/ksdH5/img/planList/plan_yqxIcon.png' class='planList_listBox_icon'>";
									}else if(plan.status=="10B"){//执行中
										planStr +="<img src='/ksdH5/img/planList/plan_zxzIcon.png' class='planList_listBox_icon'>";
									}else if(plan.status=="10D"){
										planStr +="<img src='/ksdH5/img/planList/plan_ysbIcon.png' class='planList_listBox_icon'>";
									}else if(plan.status=="10E"){
										planStr +="<img src='/ksdH5/img/planList/plan_ywcIcon.png' class='planList_listBox_icon'>";
									}
									planStr +="<div class='planList_listBox_left'>";
									planStr +="<img src='"+plan.cCImg+"' />";
									planStr +="</div>";
									planStr +="<div class='planList_listBox_right'>";
									planStr +="<div class='planList_listBox_right_top'>";
									planStr +="<div class='planList_listBox_right_top_title'>";
									planStr +="<strong>"+plan.short_cn_name+"</strong>";
									planStr +="<span>创建时间:"+getDate(plan.createTime)+"</span>";
									planStr +="</div>";
									planStr +="<div class='planList_listBox_right_top_time'>";
									planStr +="到期日:"+getDate(plan.endTime);
									planStr +="</div>";
									planStr +="</div>";
									planStr +="<div class='planList_listBox_right_bottom'>";
									planStr +="<div class='planList_listBox_right_bottom_left'>";
									planStr +="<strong>"+plan.planAmt+"</strong>";
									planStr +="<span>计划还款</span>";
									planStr +="</div>";
									planStr +="<div class='planList_listBox_right_bottom_middle'>";
									planStr +="<strong>"+plan.payed+"</strong>";
									planStr +="<span>实际还款</span>";
									planStr +="</div>";
									planStr +="<div class='planList_listBox_right_bottom_right'>";
									planStr +="<strong>"+plan.fred+"</strong>";
									planStr +="	<span>实扣手续费</span>";
									planStr +="	</div>";
									planStr +="	</div>";
									planStr +="	</div>";
									planStr +="	</a>";
									planStr +="	</li>";
								})
								$("#plan_list_ul").html(planStr);
							} else {
								$(".planList_noData").show();
								$("#plan_list_ul").hide();
							}
						}
				}
			}); 
    	})
    </script>
<script type="text/javascript">
mui.init({
	swipeBack:true
})
/*打开新的下载页面窗口*/
$(document).on('click','#uploadBnt',function(){
	window.open("https://fir.im/Katimes");
})
/*左边导航*/
$(document).on('click','.headerBox_left',function(){
	$('.huiseBox').show();
	$('.leftNavContBox').show();
	$('.headerBox_leftClose').show();
	$('.headerBox_left').hide();
	$("body").attr("style","left:5.48rem;position:fixed;"); 
	$(".headerBox").css('left','5.48rem');   
});
$(document).on('click','.headerBox_leftClose',function(){
	$('.huiseBox').hide();
	$('.leftNavContBox').hide();
	$('.headerBox_leftClose').hide();
	$('.headerBox_left').show();
	$("body").removeAttr("style");   
	$("body").removeAttr("style"); 
	$(".headerBox").css('left','0');   
});
</script>
<script type="text/javascript">
//滚动条到底部加载更多
$(document).scroll(function(){
	if ($(document).scrollTop() >= $(document).height() - $(window).height()) {
        var shopIndex_box_listBox = new Array()
        for (a=0;a<20;a++){
        	shopIndex_box_listBox[a] = ''
        }
		for(i=0;i<shopIndex_box_listBox.length;i++){
			$(".planList_listBox").append(shopIndex_box_listBox[i]);
		}
        
        /*$.ajax({
        	type:"post",
        	url:"",
        	async:true,
			dataType:"json",
			success:function(data){
				for (var i = 0; i < sum; i++) {   
	                result +=	''
	            }
				$('.planList_listBox').append(result);
			},
			error:function(){
				alert('数据有误');
			}
        }); */
	}
});

function getDate(timestamp){
	var time = new Date(timestamp);
	var year = time.getFullYear();
	var month = time.getMonth()+1;
	var date = time.getDate();
	return year+"-"+month+"-"+date;
}
</script>
</html>
